package com.zzptc.myapp8;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.zzptc.myapp8.entity.Record;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class Main3Activity extends AppCompatActivity {
    List<Record> list = new ArrayList<>();
    List lv_record;
    private static final String TAG = "Main3Activity";//logt// T+TAB

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main3);
        lv_record = findViewById(R.id.tv_rec_id)
        //list.add(new Record(1,"aaa",new Date()+""));

        for (int i = 0; i < 100; i++) {
            list.add(new Record(i, "记事" + i, new Date() + ""));
        }
        for (Record r : list) {
            //Record re=(Record)r;
            //System.out.println(r.getContent());
            Log.d(TAG, r.getContent());
        }


        MyAdapter myAdapter = new MyAdapter();



    }

    class MyAdapter extends BaseAdapter {

        @Override
        public int getCount() {
            return list.size();
        }

        @Override
        public Object getItem(int position) {
            return null;
        }

        @Override
        public long getItemId(int position) {
            return 0;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            Record record =list.get(position);//值

            View v1=View.inflate(Main3Activity.this, R.layout.item_record, null);

            TextView tv_id = v1.findViewById(R.id.tv_rec_id);
            tv_id.setText(record.getId()+"");

            TextView tv_con = v1.findViewById(R.id.tv_rec_content);
            tv_con.setText(record.getContent());


            return v1;
        }
    }
}




